package com.example.java_chatroom_redis_rabbitmq.mapper;

import org.apache.ibatis.annotations.*;

@Mapper
public interface TodoMapper {
    @Select("select count from todo where userId=#{userId} and sessionId=#{sessionId}")
    Integer getTodoCountByUserIdAndSessionId(@Param("userId") Integer userId, @Param("sessionId") Integer sessionId);

    @Update("update todo set count=count+1 where userId=#{userId} and sessionId=#{sessionId}")
    Integer addTodoCount(@Param("userId") Integer userId,@Param("sessionId") Integer sessionId);

    @Insert("insert into todo values(null,#{userId},#{sessionId},1)")
    Integer createTodoMessage(@Param("userId") Integer userId,@Param("sessionId") Integer sessionId);

    @Update("update todo set count=0 where userId=#{userId} and sessionId=#{sessionId}")
    Integer deleteTodoMessage(@Param("userId") Integer userId,@Param("sessionId") Integer sessionId);
}
